<style scoped>
    .checkLable{color:#e02222;margin-left: 6px;}
    .default-label{width: 100%;line-height: 22px;}
</style>
<template>
   <!-- <h1>新增工程替换</h1>-->
    <div>
        <!--<router-link to="/EngineeringReplacement" style="float: right">-->
            <el-button type="danger" @click="returnIndex" style="float: right" icon="close" size="mini" class="bolder outsideBtnBS"></el-button>
        <!--</router-link>-->
        <el-form :inline="true" :model="updatePlan" ref="updatePlan" style="border-bottom:1px solid #ccc;">
            <!--替换关系申请编号-->
            <el-form-item :label="nowLangue.replaceNumber" >
                <el-input size="mini" disabled v-model="updatePlan.switchCode"></el-input>
            </el-form-item>
            <!--创建人-->
            <el-form-item :label="nowLangue.founder">
                <el-input size="mini" disabled v-model="updatePlan.creator"></el-input>
            </el-form-item>
            <!--创建时间-->
            <el-form-item :label="nowLangue.creationTime" >
                <el-input size="mini" disabled v-model="updatePlan.createTime"></el-input>
            </el-form-item>
        </el-form>
        <div class="default-label">
            <!--备件替换关系明细-->
            <span v-text="nowLangue.spRecDetail"></span>
            <el-checkbox v-model="relation" disabled style="margin-left: 20px;">
                <!--同时建立与被替换备件-->
                <span class="checkLable" v-text="nowLangue.sameRecDetail  "></span>
            </el-checkbox>
            <span style="float:right;">
            </span>
        </div>
        <el-table :data="spareSwitchData" border style="width: 100%;">
            <el-table-column type="index" header-align="center" align="center" :label="nowLangue.sequence" width="40"></el-table-column>
            <!--产品线-->
            <el-table-column prop="productLineName" :label="nowLangue.productLine"  header-align="center" show-overflow-tooltip> </el-table-column>
            <!--替换备件编码-->
            <el-table-column prop="subMaterialCode" :label="nowLangue.repSpareCode"   header-align="center" show-overflow-tooltip>
            </el-table-column>
            <el-table-column prop="subMaterialName" :label="nowLangue.repSpareName"   header-align="center" show-overflow-tooltip>
            </el-table-column>
            <!--紧急-->
            <el-table-column prop="urgentflag" :label="nowLangue.urgent" header-align="center" width="60" align="center">
                <template scope="scope">
                    <el-checkbox size="mini" disabled v-model="scope.row.urgentflag" ></el-checkbox>
                </template>
            </el-table-column>
            <!--需求替换关系-->
            <el-table-column prop="reqSubTypeName" :label="nowLangue.demandRepRelation" header-align="center" >
            </el-table-column>
            <!--被替换备件编码-->
            <el-table-column prop="materialCode" :label="nowLangue.repdSpareCode" header-align="center" >
            </el-table-column>
            <!--被替换备件名称-->
            <el-table-column prop="materialName" :label="nowLangue.repdSpareName" header-align="center" show-overflow-tooltip>
            </el-table-column>
            <!--说明-->
            <el-table-column prop="description" :label="nowLangue.explain" header-align="center" show-overflow-tooltip>
            </el-table-column>
        </el-table>
    </div>
</template>
<script>
    export default {
        data() {
            return {
                nowLangue:{},
                languageScoped:{
                    zh:{
                        "pleaseSelect":"请选择",
                        "pleaseImport":"请输入",
                        "judName":"法人信息",
                        "productLine":"产品线" ,
                        "spareCode":"备件编码",
                        "spareName":"备件名称",
                        "createDate":"创建日期",
                        "to":"至",
                        "query":"查询",
                        "loadDesperately":"拼命加载中",
                        "sequence":"序",
                        "operate":"操作",
                        "addNew":"新增",
                        "submitConfirm":"提交",
                        "replaceNumber":"替换关系申请编号",
                        "founder":"创建人",
                        "creationTime":"创建时间",
                        "delete":"删除",
                        "repSpareCode":"替换备件编码",
                        "repSpareName":"替换备件名称",
                        "urgent":"紧急",
                        "demandRepRelation":"需求替换关系",
                        "repdSpareCode":"被替换备件编码",
                        "repdSpareName":"被替换备件名称",
                        "explain":"说明",
                        "spRecDetail":"备件替换关系明细",
                        "sameRecDetail":"同时建立与被替换备件",
                        "addRow":"增行",
                        "save":"保存",
                        "saveAndSubmit":"保存并提交",
                        "sure":"确定",
                        "chose":"选择"
                    },
                    en:{
                        "pleaseSelect":"please select",
                        "pleaseImport":"please import ",
                        "judName":"jud Name",
                        "productLine":"product Line" ,
                        "spareCode":"spare Code",
                        "spareName":"spare Name",
                        "createDate":"create Date",
                        "to":"to",
                        "query":"query",
                        "loadDesperately":"load Desperately",
                        "sequence":"sequence",
                        "operate":"operate",
                        "addNew":"addNew",
                        "submitConfirm":"submitConfirm",
                        "replaceNumber":"Replace relationship request number",
                        "delete":"delete",
                        "founder":"founder",
                        "creationTime":"creation time",
                        "repSpareCode":"Demand substitution relation",
                        "repSpareName":"Replacement spare parts name",
                        "urgent":"urgent",
                        "demandRepRelation":"Demand substitution relation",
                        "repdSpareCode":"Demand substitution code",
                        "repdSpareName":"Demand substitution name",
                        "explain":"explain",
                        "spRecDetail":"spRecDetail",
                        "sameRecDetail":"sameRecDetail",
                        "addRow":"add row",
                        "save":"save",
                        "saveAndSubmit":"save and submit",
                        "sure":"sure",
                        "chose":"chose"
                    }
                },
                // 查询表单
                updatePlan:{
                    switchCode:"",
                    creator:"",
                    createTime:''
                },
                whichQueryFlag:false,//判断刚进入页面时调取哪个查询接口   从哪个接口进入的新增等页面就返回调取那个接口
                relation:false,//同时建立与被替换备件
                formId:"",//查询需要传的参数
                spareSwitchData:[],//列表
                dialogFormVisible:false
            };
        },
        created:function(){
            this.languageType=="zh"?this.nowLangue=this.languageScoped.zh:this.nowLangue=this.languageScoped.en;
        },
        computed:{
            languageType(){
                return this.$store.state.languageType;
            }
        },
        watch:{
            languageType(){
                this.languageType=="zh"?this.nowLangue=this.languageScoped.zh:this.nowLangue=this.languageScoped.en;
            }
        },
        //进入页面立即运行此方法
        mounted: function () {
            var _this = this;
            _this.$store.commit('currentActive', 'SeeEReplacement');
            //接收参数
            _this.formId=_this.$route.query.formId;
            this.whichQueryFlag=this.$route.query.whichQueryFlag;
            this.queryinfor();
            this.queryOpera();
        },
        methods:{
            //获取创建人员与创建时间
            queryOpera(){
                var _this=this;
                $.ajax({
                    type:'GET',
                    url:_this.metadata_service+'barCode/createInitParameter',
                    cache:false,
                    dataType:'JSON',
                    contentType:"application/json;charset=utf-8",
                    success:function(data){
                        if(data.success){
                            _this.updatePlan.creator=data.data.personName;
                            _this.updatePlan.createTime=data.data.operationTime;
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            queryinfor(){
                var _this=this;
                _this.loading=true;
                $.ajax({
                    type: 'GET',
                    url: _this.metadata_service+"projectSubstitute/queryProjectSubstituteByFormId?formId="+_this.formId,
                    cache: false,
                    dataType:'JSON',
                    contentType: "application/json;charset=utf-8",
                    success: function (data) {
                        if (data.success) {
                            _this.saveSpareInfor=data.data.items[0];
                            _this.spareSwitchData=data.data.items;
                            _this.updatePlan.switchCode=data.data.no;
                            _this.relation=data.data.relation;
                        }else{
                            _this.loading=false;
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                });
            },
            returnIndex(){
                this.$router.push({ path: 'EngineeringReplacement', query: { whichQueryFlag:this.whichQueryFlag}})
            }
        }
    }
</script>